package com.zzyl.nursing.mapper;

import java.time.LocalTime;
import java.util.List;

import com.zzyl.nursing.domain.Device;
import com.zzyl.nursing.domain.Elder;
import com.zzyl.nursing.domain.FamilyMember;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.nursing.domain.FamilyMemberElder;
import com.zzyl.nursing.dto.ElderDto;
import com.zzyl.nursing.vo.FamilyVo;
import com.zzyl.nursing.vo.PropertyStatusInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 老人家属Mapper接口
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@Mapper
public interface FamilyMemberMapper extends BaseMapper<FamilyMember>
{
    /**
     * 查询老人家属
     * 
     * @param id 老人家属主键
     * @return 老人家属
     */
    public FamilyMember selectFamilyMemberById(Long id);

    /**
     * 查询老人家属列表
     * 
     * @param familyMember 老人家属
     * @return 老人家属集合
     */
    public List<FamilyMember> selectFamilyMemberList(FamilyMember familyMember);

    /**
     * 新增老人家属
     * 
     * @param familyMember 老人家属
     * @return 结果
     */
    public int insertFamilyMember(FamilyMember familyMember);

    /**
     * 修改老人家属
     * 
     * @param familyMember 老人家属
     * @return 结果
     */
    public int updateFamilyMember(FamilyMember familyMember);

    /**
     * 删除老人家属
     * 
     * @param id 老人家属主键
     * @return 结果
     */
    public int deleteFamilyMemberById(Long id);

    /**
     * 批量删除老人家属
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFamilyMemberByIds(Long[] ids);

    int insertFamily(Elder elder);


    Elder selectFamily(ElderDto elderDto);

    void insertZhong(@Param("elder") Elder elder, @Param("userId") Long userId);

    @Select("select * from family_member_elder")
    List<FamilyVo> findMyFamily();

    @Select("select * from family_member_elder where family_member_id = #{userId}")
    List<FamilyMemberElder> findMyFamilyByFamilyId(Long userId);

    @Select("select * from elder where id = #{elderId}")
    Elder findElderById(Long elderId);

    @Select("select room_id from bed where id = #{bedId}")
    Long findRoomId(Long bedId);

    @Select("select name from room_type where id = #{roomId}")
    String findRoomName(Long roomId);

    @Select("select * from device where binding_location = #{id}")
    Device findDevice(Long id);

    List<PropertyStatusInfo> queryDeviceDataListByDay(@Param("functionId") String functionId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("iotId") String iotId);

    List<PropertyStatusInfo> queryDeviceDataListByWeek(@Param("functionId") String functionId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("iotId") String iotId);

    @Delete("delete from family_member_elder where id = #{id}")
    int deleteByMId(Long id);

    @Select("select elder_id from family_member_elder where id = #{id}")
    int findByMid(Long id);

    @Delete("delete from family_member where id = #{eldId}")
    void deleteByEldId(int eldId);
}
